
<!-- create begin -->
<div class=" create">
   
    <!-- 表单 -->   
    <section class="panel-body" >
            <form role="form" class="form-create">

                <div class="form-group col-sm-6">
                    <span>客户类型</span>
                    <select name="type" class="form-control" v-model="type">
                        <option value="0">个人</option>
                        <option value="1">商家</option>
                    </select>
                </div>

                <div class="form-group col-sm-6" v-show="type">
                    <span>公司名称</span>
                    <input type="text" class="form-control" placeholder="公司名称" name="title">
                </div>
             
                <div class="form-group col-sm-6" v-show="type">
                    <span>社会信用代码</span>
                    <input type="text" class="form-control" placeholder="社会信用代码" name="credit_id">
                </div>

                <div class="form-group col-sm-6" v-show="type">
                    <span>纳税人识别号</span>
                    <input type="text" class="form-control" placeholder="纳税人识别号" name="taxpayer_id">
                </div>

                <div class="form-group col-sm-6" v-show="type">
                    <span>开户银行</span>
                    <select name="bank" class="form-control bank">
                        <option :value="item" v-for="item in bank" v-text="item"></option>
                    </select>

                </div>

                <div class="form-group col-sm-6" v-show="type">
                    <span>开户卡号</span>
                    <input type="text" class="form-control" placeholder="开户卡号" name="bank_number">
                </div>

                <div class="form-group col-sm-12" v-show="type">
                    <span>开户行地址</span>
                    <input type="text" class="form-control" placeholder="联系人" name="bank_address">
                </div>

                <div class="form-group col-sm-6">
                    <span>联系人</span>
                    <input type="text" class="form-control" placeholder="联系人" name="contact">
                </div>

                <div class="form-group col-sm-6" v-show="type">
                    <span>电话</span>
                    <input type="text" class="form-control" placeholder="电话" name="tel">
                </div>

                <div class="form-group col-sm-6" v-show="type">
                    <span>传真</span>
                    <input type="text" class="form-control" placeholder="传真" name="fax">
                </div>

                <div class="form-group col-sm-6">
                    <span>手机</span>
                    <input type="text" class="form-control" placeholder="手机" name="phone">
                </div>

                <div class="form-group col-sm-6">
                    <span>邮箱</span>
                    <input type="text" class="form-control" placeholder="邮箱" name="email">
                </div>                

                <div class="form-group col-sm-12">
                    <span>状态</span>
                    <div class="radio">
                        <label><input type="radio" name="status" value="0" checked="checked">正常</label>
                    </div>
                    <div class="radio">
                        <label><input type="radio" name="status" value="1" >禁用</label>
                    </div>
                </div>

                <div class="form-group col-sm-12">
                    <span>地区</span>
                    <div data-toggle="distpicker" class="distpicker col-sm-12">
                        <select class="form-control col-sm-3" name="province" style="width:auto;"></select>
                        <select class="form-control col-sm-2" name="city" style="width:auto;"></select>
                        <select class="form-control col-sm-2" name="district" style="width:auto;"></select>
                    </div>
                </div>

                <div class="form-group col-sm-12">
                    <span>街道地址</span>
                    <input type="text" class="form-control" placeholder="街道地址" name="street">
                </div>

                <div class="form-group col-sm-12">
                    <span>备注</span>
                    <textarea class="form-control" cols="5" name="desc"></textarea>
                </div>

            </form>
    </section>

    <div class="form-group col-sm-12 panel-footer bg-none">
        <button type="button" class="btn btn-sm btn btn-primary" @click="save">  保 存 </button>
        <button type="reset" class="btn btn-sm btn-success ">  重 置 </button> 
    </div>

</div>
<!-- create end-->

<script>

// seajs
seajs.use(['vendor/bank','js/distpicker.min','vendor/comboSelect/jquery.combo.select'],function() {
    var create = new Vue({
        el: '.create',
        data: {
            type: 0,
            bank: bank_list
        },
        mounted: function(){
            $(".distpicker").distpicker(); 
            $('.bank').comboSelect();
        },
        methods: {
            save: function () {
                var param = $('.form-create').serializeArray();
                $.ajax({
                    url: "{:url('save')}",
                    method: 'POST',
                    dataType: 'json',
                    data: param,
                    success: this.callback
                });
            },
            callback:function (data) {
                if( data.error >0 ){
                    toastr.error(data.msg);
                }else{
                    toastr.success(data.msg);
                    Table.methods.refresh();
                    layer.closeAll('page');
                }
            }
        },
        watch:{
            type:function(newVal,oldVal){
                this.type = (newVal == '1') ? 1 : 0;
            }
        }

    });

});

</script>